diff --git a/inc/config.php b/inc/config.php index 0ea25b46..2cbecdc3 100644 --- a/inc/config.php +++ b/inc/config.php @@ -826,6 +826,8 @@ // How many actions to show per page in the moderation log $config['mod']['modlog_page'] = 350; + // How many bans to show per page in the ban list + $config['mod']['banlist_page'] = 350; // Maximum number of results to display for a search, per board $config['mod']['search_results'] = 75; diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 98851c52..3c3c08a4 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -246,7 +246,7 @@ function mod_ban() { header('Location: ?/', true, $config['redirect_http']); } -function mod_bans() { +function mod_bans($page_no = 1) { global $config; if (!hasPermission($config['mod']['view_banlist'])) @@ -272,23 +272,27 @@ function mod_bans() { } if ($config['mod']['view_banexpired']) { - $query = prepare("SELECT `bans`.*, `username` FROM `bans` LEFT JOIN `mods` ON `mod` = `mods`.`id` ORDER BY (`expires` IS NOT NULL AND `expires` < :time), `set` DESC"); - $query->bindValue(':time', time(), PDO::PARAM_INT); - $query->execute() or error(db_error($query)); + $query = prepare("SELECT `bans`.*, `username` FROM `bans` LEFT JOIN `mods` ON `mod` = `mods`.`id` ORDER BY (`expires` IS NOT NULL AND `expires` < :time), `set` DESC LIMIT :offset, :limit"); } else { // Filter out expired bans - $query = prepare("SELECT `bans`.*, `username` FROM `bans` INNER JOIN `mods` ON `mod` = `mods`.`id` WHERE `expires` = 0 OR `expires` > :time ORDER BY `set` DESC"); - $query->bindValue(':time', time(), PDO::PARAM_INT); - $query->execute() or error(db_error($query)); + $query = prepare("SELECT `bans`.*, `username` FROM `bans` INNER JOIN `mods` ON `mod` = `mods`.`id` WHERE `expires` = 0 OR `expires` > :time ORDER BY `set` DESC LIMIT :offset, :limit"); } + $query->bindValue(':time', time(), PDO::PARAM_INT); + $query->bindValue(':limit', $config['mod']['modlog_page'], PDO::PARAM_INT); + $query->bindValue(':offset', ($page_no - 1) * $config['mod']['modlog_page'], PDO::PARAM_INT); + $query->execute() or error(db_error($query)); $bans = $query->fetchAll(PDO::FETCH_ASSOC); + $query = prepare("SELECT COUNT(*) FROM `bans`"); + $query->execute() or error(db_error($query)); + $count = $query->fetchColumn(0); + foreach ($bans as &$ban) { if (filter_var($ban['ip'], FILTER_VALIDATE_IP) !== false) $ban['real_ip'] = true; } - mod_page('Ban list', 'mod/ban_list.html', array('bans' => $bans)); + mod_page('Ban list', 'mod/ban_list.html', array('bans' => $bans, 'count' => $count)); } function mod_delete($board, $post) { diff --git a/mod.php b/mod.php index 78205bd3..86169b59 100644 --- a/mod.php +++ b/mod.php @@ -40,6 +40,7 @@ $pages = array( '!^/IP/([\w.:]+)$!' => 'ip', // view ip address '!^/IP/([\w.:]+)/remove_note/(\d+)$!' => 'ip_remove_note', // remove note from ip address '!^/bans$!' => 'bans', // ban list + '!^/bans/(\d+)$!' => 'bans', // ban list '!^/(\w+)/delete/(\d+)$!' => 'delete', // delete post diff --git a/templates/mod/ban_list.html b/templates/mod/ban_list.html index 00b8a0f4..66471d6d 100644 --- a/templates/mod/ban_list.html +++ b/templates/mod/ban_list.html @@ -72,3 +72,12 @@

{% endif %} + +{% if count > bans|count %} +

+ {% for i in range(0, count / config.mod.modlog_page) %} + [{{ i + 1 }}] + {% endfor %} +

+{% endif %} +